//
//  UIBarButtonItem+Extensions.swift
//  WB
//
//  Created by macssss on 16/6/30.
//  Copyright © 2016年 macssss. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    ///创建UIbarbuttonItem
    convenience init(title: String, fontSize: CGFloat = 16, target: AnyObject, action: Selector, isBack: Bool = false) {
        
        
        let but: UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray(), highlightedColor: UIColor.orange())
        
        if isBack {
            
            let  image = "navigationbar_back_withtext"
            but.setImage(UIImage(named: image), for: UIControlState(rawValue: 0))
            but.setImage(UIImage(named: image + "_highlighted"), for: .highlighted)
            
        }  
        
        but.sizeToFit()
        
        but.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView: but)
    }
    
} 
